
package gui;


import java.io.File;
import javax.swing.filechooser.*;

/**
 * Trida, ktera dedi File Filter, a nastavujej jej jen na
 * pts soubory - soubory s casticemi.
 * @author Tomas Drimal
 */
public class PtcsFFilter extends FileFilter {

    //Accept all directories and all pts files.
    public boolean accept(File f) {
        if (f.isDirectory()) {
            return true;
        }

        String ext = null;
        String s = f.getName();
        int i = s.lastIndexOf('.');

        if (i > 0 && i < s.length() - 1) {
            ext = s.substring(i + 1).toLowerCase();
        }

        if (ext != null) {
            if (ext.equals("pts")) {
                return true;
            } else {
                return false;
            }
        }

        return false;
    }

    //The description of this filter
    public String getDescription() {
        return "Only Particles Files (*.pts)";
    }
}
